<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<input type="button" name="" id="openW" value="点击" />
		<input type="button" name="" id="closeW" value="关闭" />
	</body>
	<script type="text/javascript">
		// 打开窗口
		//自动调用open方法,除了ie之外,其他浏览器会认为是弹出广告,会阻止
		window.open('https://www.baidu.com');
		
		document.getElementById('openW').onclick = function() {
			window.open('https://www.baidu.com','_self');
		}
		
		// 关闭窗口
		document.getElementById('closeW').onclick = function() {
			window.open('');
			window.close();
		}
		
	</script>

</html>